﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Index.cshtml";
}
    <script>
        layui.use(['jquery', 'form', 'table', 'common', 'tablePlug', "layer"], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                layer = layui.layer,
                common = layui.common;
            //加载数据
            wcLoading.close();
            var value = $.request("value");
            var name = $.request("name");
            var ids = $.request("ids");
            common.rendertable({
                elem: '#currentTableId',
                id: 'currentTableId',
                url: '/SystemOrganize/Role/GetSelectJson?ids=' + (!!ids ? ids : ""),
                page: false,
                height: 'full-35',
                toolbar: false,//工具栏
                id: 'currentTableId',
                sqlkey: 'F_Id',//数据库主键
                cols: [[
                    { type: 'checkbox' },
                    { field: 'F_Id', title: 'ID', sort: true, fixed: "left", hide: true, hideAlways: true },
                    { field: 'F_FullName', title: '角色名称', width: 120, sort: true },
                    {
                        field: 'F_Type', title: '角色类型', width: 120, sort: true,
                        templet: function (d) {
                            return top.clients.dataItems["RoleType"][d.F_Type] == undefined ? "" : top.clients.dataItems["RoleType"][d.F_Type];
                        }
                    },
                    {
                        field: 'F_OrganizeId', title: '归属公司', width: 120, sort: true,
                        templet: function (d) {
                            return top.clients.organize[d.F_OrganizeId] == undefined ? "" : top.clients.organize[d.F_OrganizeId].fullname;
                        }
                    },
                    {
                        field: 'F_EnabledMark', title: '状态', width: 120, sort: true,
                        templet: function (d) {
                            if (d.F_EnabledMark == true) {
                                return "<span class=\"layui-bg-green\">正常</span>";
                            } else {
                                return "<span class=\"layui-bg-red\">禁用</span>";
                            }
                        }
                    }
                ]]
            });

            // 监听提交操作
            var lock = false;
            form.on('submit(saveBtn)', function (data) {
                if (!lock) {
                    var checkStatus = table.checkStatus("currentTableId").data;
                    var pvalue = [];
                    var pname = [];
                    for (var i = 0; i < checkStatus.length; i++) {
                        pvalue.push(checkStatus[i].F_Id);
                        pname.push(checkStatus[i].F_FullName);
                    }
                    if (!!pvalue) {
                        parent.$('#' + value).val(pvalue.join(","));
                    }
                    if (!!pname) {
                        parent.$('#' + name).val(pname.join(","));
                    }
                    common.modalClose();
                    lock = false;
                }
                return false;
            });
        });
    </script>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="table-search-fieldset layui-hide">
            @*<legend>搜索信息</legend>*@
            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">关键字:</label>
                            <div class="layui-input-inline">
                                <input type="text" id="txt_keyword" name="txt_keyword" autocomplete="off" class="layui-input" placeholder="">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon">&#xe615;</i> 搜 索</button>
                        </div>
                    </div>
                    <div class="layui-form-item layui-hide">
                        <button class="layui-btn" lay-submit id="submit" lay-filter="saveBtn">确认保存</button>
                    </div>
                </form>
            </div>
        </fieldset>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
    </div>
</div>